ps.boxplot <- function(ps.obj, file = "~/Desktop/pbox.pdf", pdf = TRUE, vars = c("xnorm", "xunif", "xchi"), assgs = c("tbl", "tcr", "tra"), wh.test = "", boxwxx = .1, varspace = .01, assg.names = c("BL", "CR", "RA"), mainlab){
  ps.obj <- ps.obj[["pvals.df"]]                                                                             
  ps.obj$varn <- 1
  ps.obj$varn[ps.obj$var == "xnorm"] <- 3
  ps.obj$varn[ps.obj$var == "xunif"] <- 2                                                                                 
  n.var <- length(vars)
  n.assg <- length(assgs)
  barspace <- boxwxx+.01                                                                               
  if(pdf == TRUE){
    pdf(file)
  }

  boxplot(p ~ varn, data = ps.obj[ps.obj$assg == assgs[1] & ps.obj$test == wh.test,], boxwex = boxwxx, 
          at = c(1-varspace, 2, 3+varspace)/(n.var + 1)+barspace, xlab = "p-values", horizontal = TRUE, las=1, ylim = c(0,1), xlim=c(0,1), 
          names = paste(assg.names[1], rev(vars)), cex.axis =.8, main = mainlab)
  for(a.idx in 2:n.assg){
    boxplot(p ~ varn, data = ps.obj[ps.obj$assg == assgs[a.idx] & ps.obj$test == wh.test,], boxwex = boxwxx, add = TRUE,
            at = c(1-varspace, 2, 3+varspace)/(n.var + 1)-(a.idx-n.assg+1)*barspace, xlab = "", horizontal = TRUE, las = 1, 
            names = paste(assg.names[a.idx], rev(vars)), cex.axis = .8)                                                                           
  }
  if(pdf == TRUE){
    dev.off()
  }
}
